package trunk.view;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;

import trunk.control.UsuarioControlador;
import trunk.model.BancoDeClientes;
import trunk.model.BancoDeConvidados;
import trunk.model.TipoSala;

@SuppressWarnings("serial")
public class TelaParticipantesON extends JFrame{
	private JButton add;
	private JButton addAll;
	private JButton remove;
	private JButton removeAll;
	private JButton cancelar;
	private JButton convidar;
        private JButton batePapo;
	private JScrollPane jScrollPane1;
	private JScrollPane jScrollPane2;
	private JTable toInvite;
	private JTable inviteds;
	private TableModelClientes toInviteModel;
	private TableModelClientes invitedsModel;
	private BancoDeClientes usuarios;
	private BancoDeClientes convidados;
	private TipoSala tipoSala;
        

	public TelaParticipantesON(UsuarioControlador controlador, BancoDeClientes clientes, TipoSala tipoSala) {
		super("Convidar");
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		setExtendedState(JFrame.MAXIMIZED_BOTH);
		setResizable(false);
		
		this.tipoSala = tipoSala;

		add = new JButton(">");
		add.addActionListener(controlador);
		addAll = new JButton(">>");
		addAll.addActionListener(controlador);
		remove = new JButton("<");
		remove.addActionListener(controlador);
		removeAll = new JButton("<<");
		removeAll.addActionListener(controlador);
		convidar = new JButton("Convidar");
		convidar.addActionListener(controlador);
		cancelar = new JButton("Cancelar");
		cancelar.addActionListener(controlador);

		this.usuarios = clientes;
		toInviteModel = new TableModelClientes(usuarios);
		toInvite = new JTable(toInviteModel);
		
		convidados = new BancoDeClientes();
		invitedsModel = new TableModelClientes(convidados);
		inviteds = new JTable(invitedsModel);
		
		jScrollPane1 = new JScrollPane();
		jScrollPane1.setViewportView(toInvite);
		
		jScrollPane2 = new JScrollPane();
		jScrollPane2.setViewportView(inviteds);
		
		javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 379, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(add, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(addAll))
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(remove, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(removeAll)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 379, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap())
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(convidar)
                        .addGap(18, 18, 18)
                        .addComponent(cancelar)
                        .addGap(286, 286, 286))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(73, 73, 73)
                        .addComponent(add)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(addAll)
                        .addGap(33, 33, 33)
                        .addComponent(remove)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(removeAll))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 244, Short.MAX_VALUE)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 244, Short.MAX_VALUE))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(convidar)
                    .addComponent(cancelar))
                .addGap(20, 20, 20))
        );

        pack();
        setLocationRelativeTo(null);
        setVisible(true);
	}

	public JButton getRemoveAll() {
		return removeAll;
	}

	public void setRemoveAll(JButton removeAll) {
		this.removeAll = removeAll;
	}

	public JButton getAdd() {
		return add;
	}

	public JButton getAddAll() {
		return addAll;
	}

	public JButton getRemove() {
		return remove;
	}

	public JButton getCancelar() {
		return cancelar;
	}

	public JButton getConvidar() {
		return convidar;
	}

	public void setUsuarios(BancoDeClientes usuarios) {
		this.usuarios = usuarios;
		toInviteModel.linhas = usuarios.getBancoDeClientes();
		toInviteModel.fireTableDataChanged();
	}

	public void setConvidados(BancoDeClientes convidados) {
		this.convidados = convidados;
		invitedsModel.linhas = convidados.getBancoDeClientes();
		invitedsModel.fireTableDataChanged();
	}
	public JTable getToInvite() {
		return toInvite;
	}

	public void setToInvite(JTable toInvite) {
		this.toInvite = toInvite;
	}

	public JTable getInviteds() {
		return inviteds;
	}

	public void setInviteds(JTable inviteds) {
		this.inviteds = inviteds;
	}

	public BancoDeClientes getUsuarios() {
		return usuarios;
	}

	public BancoDeClientes getConvidados() {
		return convidados;
	}

	public TipoSala getTipoSala() {
		return tipoSala;
	}

	public void setTipoSala(TipoSala tipoSala) {
		this.tipoSala = tipoSala;
	}

}
